<ui:composition template="/faces/geral/layout.xhtml" 
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:t="http://myfaces.apache.org/tomahawk"	
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:custom="http://www.it4solutions.com.br/custom">

	<ui:define name="content">
	
		<h:form id="consultaAtendimentoForm">
			
			<!-- Filtro Consulta de Atendimento -->		
			<h:panelGrid columns="4" cellpadding="0" columnClasses="atendimento-filter-col-right, atendimento-filter-col-left, atendimento-filter-col-right, atendimento-filter-col-left">
				<h:outputText value="#{msg['atendimento.paciente']}" styleClass="output-text"/>
				<rich:autocomplete value="#{atendimentoBean.atendimentoFilter.paciente.nome}" mode="cachedAjax" minChars="3" autofill="false"
					autocompleteList="#{atendimentoBean.pacienteAutocompleteList}" autocompleteMethod="#{atendimentoBean.pacienteAutocompleteListener}" 
					inputClass="autocomplete-input" popupClass="autocomplete-popup" selectedItemClass="autocomplete-selected"/>
				<h:outputText value="#{msg['geral.data']}" styleClass="output-text"/>
				<rich:calendar id="dataCalendar" value="#{atendimentoBean.atendimentoFilter.data}" datePattern="#{msg['geral.formato.data']}" enableManualInput="true" inputSize="10" inputClass="calendar-input"/>

				<h:outputText value="#{msg['atendimento.medico.requisitante']}" styleClass="output-text"/>
				<rich:autocomplete value="#{atendimentoBean.atendimentoFilter.medicoRequisitante.nome}" mode="cachedAjax" minChars="3" autofill="false"
					autocompleteList="#{atendimentoBean.medicoAutocompleteList}" autocompleteMethod="#{atendimentoBean.medicoAutocompleteListener}" 
					inputClass="autocomplete-input" popupClass="autocomplete-popup" selectedItemClass="autocomplete-selected"/>
				<h:outputText value="#{msg['atendimento.convenio']}" styleClass="output-text"/> 
				<h:selectOneMenu value="#{atendimentoBean.atendimentoFilter.convenio}" converter="entityConverter" styleClass="select-one-menu">
					<f:selectItem itemLabel="#{msg['geral.selecione.opcao']}"/>
					<t:selectItems value="#{atendimentoBean.convenios}" var="convenio" itemValue="#{convenio}" itemLabel="#{convenio.nome}"/>
				</h:selectOneMenu>				

				<h:outputText value="#{msg['atendimento.exame']}" styleClass="output-text"/> 
				<h:selectOneMenu value="#{atendimentoBean.atendimentoFilter.exame}" converter="entityConverter" styleClass="select-one-menu">
					<f:selectItem itemLabel="#{msg['geral.selecione.opcao']}"/>
					<t:selectItems value="#{atendimentoBean.exames}" var="exame" itemValue="#{exame}" itemLabel="#{exame.nome}"/>
				</h:selectOneMenu>				
				<h:outputText />
				<h:commandLink value="#{msg['geral.consultar']}" action="#{atendimentoBean.searchAtendimento}" styleClass="button button-search" render="atendimentoLista, dataScroller"/>
			</h:panelGrid>
		
			<div id="spacer-15"/>
			
			<t:dataTable id="atendimentoDataTable" var="atendimento" value="#{atendimentoBean.atendimentos}"  rows="#{atendimentoBean.pageSize}" width="100%" renderedIfEmpty="true"
				styleClass="tomahawk-data-table" headerClass="tomahawk-data-table-header" rowClasses="tomahawk-data-table-row" 
				columnClasses="atendimento-col-paciente, atendimento-col-data, atendimento-col-convenio, atendimento-col-medico, atendimento-col-exame">
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{msg['atendimento.paciente']}"/>	
					</f:facet>
					<h:outputText value="#{atendimento.paciente.nome}"/>
				</h:column>
				<h:column headerClass="tomahawk-data-table-header ">
					<f:facet name="header">
						<h:outputText value="#{msg['geral.data']}"/>	
					</f:facet>
					<h:outputText value="#{atendimento.data}">
						<f:convertDateTime pattern="#{msg['geral.formato.data']}" />
					</h:outputText>
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{msg['atendimento.convenio']}"/>	
					</f:facet>
					<h:outputText value="#{atendimento.convenio.nome}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{msg['atendimento.medico.requisitante']}"/>	
					</f:facet>
					<h:outputText value="#{msg['geral.dr']} #{atendimento.medicoRequisitante.nome}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="#{msg['atendimento.exame']}"/>
					</f:facet>
					<h:outputText value="#{atendimento.exame.nome}" />
				</h:column>
				
			</t:dataTable>
			
			<h:panelGrid width="100%" columns="3" cellpadding="1" cellspacing="0" columnClasses="scroller-table-col-left, scroller-table-col-middle, scroller-table-col-right">
				<custom:dataScrollerNumber rowCount="#{atendimentoBean.atendimentos.rowCount}" rendered="#{not empty atendimentoBean.atendimentos.wrappedData}"/>
				<custom:dataScroller id="dataScroller" forComponent="atendimentoDataTable" maxPages="#{atendimentoBean.paginatorMaxPages}" actionListenerBackbean="#{atendimentoBean}" actionListenerMethod="pageListener"/>
				<custom:dataScrollerPage currentPage="#{atendimentoBean.atendimentos.currentPage}" pageCount="#{atendimentoBean.atendimentos.pageCount}" rendered="#{atendimentoBean.atendimentos.rowCount > atendimentoBean.pageSize}"/>
			</h:panelGrid>
			
		</h:form>

 	</ui:define>
</ui:composition>
